package com.qw.badge.sample

import android.content.Context
import android.net.Uri
import android.os.Bundle


/**
 * Created by qinwei on 2021/6/20 5:23 下午
 * email: qinwei_it@163.com
 */
class HuaweiBadge : IBadge {
    override fun setBadgeNum(context: Context, num: Int) {
        try {
            val bundle = Bundle()
            bundle.putString("package", context.packageName) // com.test.badge is your package name
            bundle.putString(
                "class",
                MainActivity::class.java.canonicalName
            ) // com.test. badge.MainActivity is your apk main activity
            bundle.putInt("badgenumber", num)
            context.contentResolver.call(
                Uri.parse("content://com.huawei.android.launcher.settings/badge/"),
                "change_badge",
                null,
                bundle
            )
        } catch (e: Exception) {
        }
    }
}